package com.demo.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Tan-Bowen
 * @version 1.0
 * @description TODO
 * @date 2021/7/29 12:06
 */
public interface OftenEnum {


    /**
     * @author Tan-Bowen
     * @description TODO 公用启用禁用枚举
     * @date 2021/7/29 12:15
     */
    @AllArgsConstructor
    @Getter
    public enum EnableState {
        ENABLE("启用", 1),
        DISABLE("禁用", 0);

        private final String title;
        private final Integer code;

        public String title() {
            return this.title;
        }

        public Integer code() {
            return this.code;
        }

        public boolean eq(Integer code) {
            return code.equals(this.code);
        }

        static ConcurrentHashMap<Integer, EnableState> map = new ConcurrentHashMap<>();

        static {
            for (EnableState value : values()) {
                map.put(value.getCode(), value);
            }
        }

        public static EnableState parse(Integer code) {
            return map.get(code);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum MenuType {
        MENU("菜单", 0),
        AUTH("功能", 1);

        private final String title;
        private final Integer code;

        public String title() {
            return this.title;
        }

        public Integer code() {
            return this.code;
        }

        static ConcurrentHashMap<Integer, MenuType> map = new ConcurrentHashMap<>();

        static {
            for (MenuType value : values()) {
                map.put(value.getCode(), value);
            }
        }

        public static MenuType parse(Integer code) {
            return map.get(code);
        }
    }

    @AllArgsConstructor
    @Getter
    public enum Super {
        SUPER_MAN("超级管理员", 0),
        DEFAULT("默认查询", -1);

        private final String title;
        private final Integer code;

        public String title() {
            return this.title;
        }

        public Integer code() {
            return this.code;
        }

    }

    @AllArgsConstructor
    @Getter
    public enum InterfaceType {
        PUBLIC("开放接口", 1),
        POWER("鉴权接口", 2);

        private final String title;
        private final Integer code;

        public String title() {
            return this.title;
        }

        public Integer code() {
            return this.code;
        }

    }

    @AllArgsConstructor
    @Getter
    public enum DelEnum {
        YES_DEL("删除", 1),
        NO_DEL("未删除", 0);

        private final String title;
        private final Integer code;

        public String title() {
            return this.title;
        }

        public Integer code() {
            return this.code;
        }

        public boolean eq(Integer code) {
            return code.equals(this.code);
        }

    }
}
